<template>
  <div id="paicharts2"></div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "PAicharts2",
  data() {
    return {
      chart: null,
      options: null,
    };
  },
  mounted() {
    this.$nextTick(function () {
      this.initcharts();
    });
  },
  methods: {
    initcharts() {
      this.chart = echarts.init(document.getElementById("paicharts2"));
      this.options = {
        //你的代码
    
        title: {
          show: false,
        },
        tooltip: {
          trigger: "axis",
          backgroundColor: "rgba(13,5,30,.6)",
          borderWidth: 1,
          borderColor: "#32A1FF",
          padding: 5,
          textStyle: {
            color: "#fff",
          },
        },
        legend: {
          right: "center",
          top: 5,
          // icon: 'circle',
          itemWidth: 14,
          itemHeight: 10,
          itemGap: 37,
          textStyle: {
            fontSize: 14,
            fontFamily: "Source Han Sans CN",
            fontWeight: "normal",
            color: "#FFFFFF",
          },
        },
        grid: {
          x: "3%",
          y: "15%",
          x2: "5%",
          y2: "5%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          axisLabel: {
            color: "rgba(255, 255, 255, 0.8)",
            fontSize: 14,
            interval: 0,
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "#2D4377",
            },
          },
          axisTick: {
            show: false,
          },
          splitLine: {
            show: false,
            lineStyle: {
              color: "#2D4377",
              type: "dotted",
            },
          },
          data: [
            "埠头镇",
            "大战乡",
            "安岭乡",
            "广度乡",
            "横溪镇",
            "田市镇",
            "白塔镇",
            "淡竹乡",
            "上张乡",
          ],
        },
        yAxis: {
          type: "value",
          name: "(个)",
          min: 0,
          position: "left",
          nameTextStyle: {
            color: "#fff",
            fontSize: 14,
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "#2D4377",
            },
          },
          axisTick: {
            show: false,
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "#2D4377",
              type: "dotted",
            },
          },
          axisLabel: {
            formatter: "{value}",
            textStyle: {
              color: "#FFFFFF",
            },
          },
        }, 
        series: [
          {
            name: "总数",
            type: "bar",
            barWidth: 14,
            barGap: "40%",
            itemStyle: {
              borderWidth: 1,
              borderRadius: [3, 3, 0, 0],
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#A5ADFF", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "#9B69EC", // 100% 处的颜色
                  },
                ],
              },
            },
            data: [87, 60, 124, 20, 432, 90, 66, 174, 100],
          },
          {
            name: "离线",
            type: "bar",
            barWidth: 14,
            barGap: "40%",
            itemStyle: {
              borderWidth: 1,
              borderRadius: [3, 3, 0, 0],
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#E1B031", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "#FF8143", // 100% 处的颜色
                  },
                ],
              },
            },
            data: [90, 66, 174, 100, 430, 87, 60, 124, 20],
          },
          {
            name: "在线",
            type: "bar",
            barWidth: 14,
            barGap: "40%",
            itemStyle: {
              borderWidth: 1,
              borderRadius: [3, 3, 0, 0],
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#00BEFF", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "#247FFF", // 100% 处的颜色
                  },
                ],
              },
            },
            data: [20, 96, 140, 150, 402, 20, 96, 140, 150],
          },
          {
            name: "播放",
            type: "bar",
            barWidth: 14,
            barGap: "40%",
            itemStyle: {
              borderWidth: 1,
              borderRadius: [3, 3, 0, 0],
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#00DE92", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "#69FFEF", // 100% 处的颜色
                  },
                ],
              },
            },
            data: [20, 96, 140, 150, 402, 20, 96, 140, 150],
          },
        ],
      };
      this.chart.setOption(this.options);
    },
  },
};
</script>

<style lang="scss" scoped>
#paicharts2 {
  height: 200px;
  width: 640px;
}
</style> 